﻿Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Data
Imports System.Windows.Forms
Imports DevComponents.DotNetBar.Controls
Imports DevComponents.Editors.DateTimeAdv
Imports DoAnQuanLyBanHang1065043_1065007.DoAnQuanLyBanHang.DTO
Imports DoAnQuanLyBanHang1065043_1065007.DoAnQuanLyBanHang.General
Imports DoAnQuanLyBanHang1065043_1065007.DoAnQuanLyBanHang.BUSS

Namespace DoAnQuanLyBanHang.DAO
    Public Class DoanhThuCtrl
        Private m_DoanhThuData As New DoanhThuData()
        Private m_DoanhThuInfo As New DoanhThuInfo()

        Public Sub HienThiComboBox(cbx As ComboBox)
            Dim m_DT As DataTable = m_DoanhThuData.LayDoanhThu()
            cbx.DataSource = m_DT
            cbx.DisplayMember = "Tháng"
            cbx.ValueMember = "Tháng"
        End Sub
        Public Sub HienThiComboBox1(cbx As ComboBox)
            Dim m_DT As DataTable = m_DoanhThuData.LayDoanhThu()
            cbx.DataSource = m_DT
            cbx.DisplayMember = "Năm"
            cbx.ValueMember = "Năm"
        End Sub

        Public Shared Function LayDsDoanhThuTheoThang(thang As Integer, nam As Integer) As IList(Of DoanhThuInfo)
            Dim ds As IList(Of DoanhThuInfo) = New List(Of DoanhThuInfo)()

            Dim data As New DoanhThuData()
            Dim tbl As DataTable = data.LayDSDoanhThuTheoThang(thang, nam)

            Dim DoanhThu As IList(Of DoanhThuInfo) = New List(Of DoanhThuInfo)()

            For Each row As DataRow In tbl.Rows
                Dim DT As New DoanhThuInfo()

                Dim m_MH As New MatHangInfo()
                m_MH.TenMH = Convert.ToString(row("Tên Mặt Hàng"))
                m_MH.MaMH = Convert.ToString(row("Mã Mặt Hàng"))
                DT.Tháng = Convert.ToInt32(row("Tháng"))
                DT.Năm = Convert.ToInt32(row("Năm"))
                DT.Tổng_Nhập = Convert.ToInt64(row("Tổng Nhập"))
                DT.Tổng_Xuất = Convert.ToInt64(row("Tổng Xuất"))
                DT.Mã_Mặt_Hàng = Convert.ToString(row("Mã Mặt Hàng"))
                DT.Tên_Mặt_Hàng = Convert.ToString(row("Tên Mặt Hàng"))
                DT.MaMH = m_MH
                DoanhThu.Add(DT)
            Next
            Return DoanhThu
        End Function
    End Class
End Namespace
